<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="robots" content="noodp" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
        <title>Activiti（二）初始化 - 豆是不吃豆豉</title><meta name="Description" content="Activiti 初始化"><meta property="og:title" content="Activiti（二）初始化" />
<meta property="og:description" content="Activiti 初始化" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://dou-chi.gitee.io/activiti%E4%BA%8C%E5%88%9D%E5%A7%8B%E5%8C%96/" />
<meta property="og:image" content="https://dou-chi.gitee.io/logo.png"/>
<meta property="article:published_time" content="2020-11-20T21:24:21+08:00" />
<meta property="article:modified_time" content="2020-11-16T17:41:21+08:00" />
<meta name="twitter:card" content="summary_large_image"/>
<meta name="twitter:image" content="https://dou-chi.gitee.io/logo.png"/>

<meta name="twitter:title" content="Activiti（二）初始化"/>
<meta name="twitter:description" content="Activiti 初始化"/>
<meta name="application-name" content="豆是不吃豆豉">
<meta name="apple-mobile-web-app-title" content="豆是不吃豆豉"><meta name="theme-color" content="#ffffff"><meta name="msapplication-TileColor" content="#da532c"><link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
        <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
        <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"><link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5"><link rel="manifest" href="/site.webmanifest"><link rel="canonical" href="https://dou-chi.gitee.io/activiti%E4%BA%8C%E5%88%9D%E5%A7%8B%E5%8C%96/" /><link rel="prev" href="https://dou-chi.gitee.io/activiti%E4%B8%80%E7%AE%80%E4%BB%8B/" /><link rel="next" href="https://dou-chi.gitee.io/actdynamicprocess/" /><link rel="stylesheet" href="/lib/normalize/normalize.min.css"><link rel="stylesheet" href="/css/style.min.css"><link rel="stylesheet" href="/lib/fontawesome-free/all.min.css"><link rel="stylesheet" href="/lib/animate/animate.min.css"><script type="application/ld+json">
    {
        "@context": "http://schema.org",
        "@type": "BlogPosting",
        "headline": "Activiti（二）初始化",
        "inLanguage": "zh-CN",
        "mainEntityOfPage": {
            "@type": "WebPage",
            "@id": "https:\/\/dou-chi.gitee.io\/activiti%E4%BA%8C%E5%88%9D%E5%A7%8B%E5%8C%96\/"
        },"genre": "posts","keywords": "Activiti","wordcount":  2026 ,
        "url": "https:\/\/dou-chi.gitee.io\/activiti%E4%BA%8C%E5%88%9D%E5%A7%8B%E5%8C%96\/","datePublished": "2020-11-20T21:24:21+08:00","dateModified": "2020-11-16T17:41:21+08:00","publisher": {
            "@type": "Organization",
            "name": ""},"author": {
                "@type": "Person",
                "name": "豆是不吃豆豉"
            },"description": "Activiti 初始化"
    }
    </script></head>
    <body header-desktop="fixed" header-mobile="auto"><script type="text/javascript">(window.localStorage && localStorage.getItem('theme') ? localStorage.getItem('theme') === 'dark' : ('dark' === 'auto' ? window.matchMedia('(prefers-color-scheme: dark)').matches : 'dark' === 'dark')) && document.body.setAttribute('theme', 'dark');</script>

        <div id="mask"></div><div class="wrapper"><header class="desktop" id="header-desktop">
    <div class="header-wrapper">
        <div class="header-title">
            <a href="/" title="豆是不吃豆豉">豆是不吃豆豉</a>
        </div>
        <div class="menu">
            <div class="menu-inner"><a class="menu-item" href="/posts/"> 所有文章 </a><a class="menu-item" href="/tags/"> 标签 </a><a class="menu-item" href="/categories/"> 分类 </a><a class="menu-item" href="https://github.com/dou-chi" rel="noopener noreffer" target="_blank"> github </a><a class="menu-item" href="https://gitee.com/dou-chi" rel="noopener noreffer" target="_blank"> gitee </a><span class="menu-item delimiter"></span><span class="menu-item search" id="search-desktop">
                        <input type="text" placeholder="搜索文章标题或内容..." id="search-input-desktop">
                        <a href="javascript:void(0);" class="search-button search-toggle" id="search-toggle-desktop" title="搜索">
                            <i class="fas fa-search fa-fw"></i>
                        </a>
                        <a href="javascript:void(0);" class="search-button search-clear" id="search-clear-desktop" title="清空">
                            <i class="fas fa-times-circle fa-fw"></i>
                        </a>
                        <span class="search-button search-loading" id="search-loading-desktop">
                            <i class="fas fa-spinner fa-fw fa-spin"></i>
                        </span>
                    </span><a href="javascript:void(0);" class="menu-item theme-switch" title="切换主题">
                    <i class="fas fa-adjust fa-fw"></i>
                </a>
            </div>
        </div>
    </div>
</header><header class="mobile" id="header-mobile">
    <div class="header-container">
        <div class="header-wrapper">
            <div class="header-title">
                <a href="/" title="豆是不吃豆豉">豆是不吃豆豉</a>
            </div>
            <div class="menu-toggle" id="menu-toggle-mobile">
                <span></span><span></span><span></span>
            </div>
        </div>
        <div class="menu" id="menu-mobile"><div class="search-wrapper">
                    <div class="search mobile" id="search-mobile">
                        <input type="text" placeholder="搜索文章标题或内容..." id="search-input-mobile">
                        <a href="javascript:void(0);" class="search-button search-toggle" id="search-toggle-mobile" title="搜索">
                            <i class="fas fa-search fa-fw"></i>
                        </a>
                        <a href="javascript:void(0);" class="search-button search-clear" id="search-clear-mobile" title="清空">
                            <i class="fas fa-times-circle fa-fw"></i>
                        </a>
                        <span class="search-button search-loading" id="search-loading-mobile">
                            <i class="fas fa-spinner fa-fw fa-spin"></i>
                        </span>
                    </div>
                    <a href="javascript:void(0);" class="search-cancel" id="search-cancel-mobile">
                        取消
                    </a>
                </div><a class="menu-item" href="/posts/" title="">所有文章</a><a class="menu-item" href="/tags/" title="">标签</a><a class="menu-item" href="/categories/" title="">分类</a><a class="menu-item" href="https://github.com/dou-chi" title="" rel="noopener noreffer" target="_blank">github</a><a class="menu-item" href="https://gitee.com/dou-chi" title="" rel="noopener noreffer" target="_blank">gitee</a><a href="javascript:void(0);" class="menu-item theme-switch" title="切换主题">
                <i class="fas fa-adjust fa-fw"></i>
            </a></div>
    </div>
</header>
<div class="search-dropdown desktop">
    <div id="search-dropdown-desktop"></div>
</div>
<div class="search-dropdown mobile">
    <div id="search-dropdown-mobile"></div>
</div>
<main class="main">
                <div class="container"><div class="toc" id="toc-auto">
            <h2 class="toc-title">目录</h2>
            <div class="toc-content always-active" id="toc-content-auto"></div>
        </div><article class="page single"><h1 class="single-title animated flipInX">Activiti（二）初始化</h1><div class="post-meta">
            <div class="post-meta-line"><span class="post-author"><a href="/" title="Author" rel=" author" class="author"><i class="fas fa-user-circle fa-fw"></i>豆是不吃豆豉</a></span>&nbsp;<span class="post-category">收录于 <a href="/categories/activiti/"><i class="far fa-folder fa-fw"></i>Activiti</a></span></div>
            <div class="post-meta-line"><i class="far fa-calendar-alt fa-fw"></i>&nbsp;<time datetime="2020-11-20">2020-11-20</time>&nbsp;<i class="fas fa-pencil-alt fa-fw"></i>&nbsp;约 2026 字&nbsp;
                <i class="far fa-clock fa-fw"></i>&nbsp;预计阅读 5 分钟&nbsp;</div>
        </div><div class="details toc" id="toc-static"  kept="">
                <div class="details-summary toc-title">
                    <span>目录</span>
                    <span><i class="details-icon fas fa-angle-right"></i></span>
                </div>
                <div class="details-content toc-content" id="toc-content-static"><nav id="TableOfContents">
  <ul>
    <li>
      <ul>
        <li><a href="#流程设计插件安装">流程设计插件安装</a>
          <ul>
            <li><a href="#eclipse">Eclipse</a></li>
            <li><a href="#idea">IDEA</a></li>
          </ul>
        </li>
        <li><a href="#搭建环境">搭建环境</a>
          <ul>
            <li><a href="#activiti配置">Activiti配置</a>
              <ul>
                <li><a href="#创建-processengine">创建 ProcessEngine</a></li>
                <li><a href="#表说明">表说明</a></li>
              </ul>
            </li>
          </ul>
        </li>
      </ul>
    </li>
  </ul>
</nav></div>
            </div><div class="content" id="content"><h2 id="流程设计插件安装">流程设计插件安装</h2>
<h3 id="eclipse">Eclipse</h3>
<p>在线安装 打开 Help -&gt; Install New Software，在线安装地址如下</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span></code></pre></td>
<td class="lntd">
<pre class="chroma"><code class="language-fallback" data-lang="fallback">Name: Activiti BPMN 2.0 designer
Location: http://activiti.org/designer/update/
</code></pre></td></tr></table>
</div>
</div><p>也可以参考 <a href="https://blog.csdn.net/lovemenghaibin/article/details/50568858">https://blog.csdn.net/lovemenghaibin/article/details/50568858</a></p>
<h3 id="idea">IDEA</h3>
<p>IDEA 在2019版本之后，不再支持在线安装，需要离线安装。在线安装：菜单栏 File -&gt; Setting -&gt; Plugins 右边搜索 actiBPM，然后 install ，然后重新启动 idea 开发工具。</p>
<h2 id="搭建环境">搭建环境</h2>
<p>使用<code>maven</code>引入<code>Activiti</code></p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre class="chroma"><code><span class="lnt"> 1
</span><span class="lnt"> 2
</span><span class="lnt"> 3
</span><span class="lnt"> 4
</span><span class="lnt"> 5
</span><span class="lnt"> 6
</span><span class="lnt"> 7
</span><span class="lnt"> 8
</span><span class="lnt"> 9
</span><span class="lnt">10
</span><span class="lnt">11
</span><span class="lnt">12
</span><span class="lnt">13
</span><span class="lnt">14
</span><span class="lnt">15
</span><span class="lnt">16
</span><span class="lnt">17
</span><span class="lnt">18
</span><span class="lnt">19
</span><span class="lnt">20
</span><span class="lnt">21
</span><span class="lnt">22
</span><span class="lnt">23
</span><span class="lnt">24
</span><span class="lnt">25
</span><span class="lnt">26
</span><span class="lnt">27
</span><span class="lnt">28
</span><span class="lnt">29
</span><span class="lnt">30
</span><span class="lnt">31
</span><span class="lnt">32
</span><span class="lnt">33
</span><span class="lnt">34
</span><span class="lnt">35
</span><span class="lnt">36
</span><span class="lnt">37
</span></code></pre></td>
<td class="lntd">
<pre class="chroma"><code class="language-xml" data-lang="xml">    <span class="nt">&lt;properties&gt;</span>
        <span class="nt">&lt;activiti-version&gt;</span>5.22.0<span class="nt">&lt;/activiti-version&gt;</span>
        <span class="nt">&lt;mysql-version&gt;</span>8.0.22<span class="nt">&lt;/mysql-version&gt;</span>
        <span class="nt">&lt;junit-version&gt;</span>4.13<span class="nt">&lt;/junit-version&gt;</span>
        <span class="nt">&lt;sl4j-log4j-version&gt;</span>1.7.2<span class="nt">&lt;/sl4j-log4j-version&gt;</span>
    <span class="nt">&lt;/properties&gt;</span>

    <span class="nt">&lt;dependencies&gt;</span>
        <span class="c">&lt;!--activiti--&gt;</span>
        <span class="nt">&lt;dependency&gt;</span>
            <span class="nt">&lt;groupId&gt;</span>org.activiti<span class="nt">&lt;/groupId&gt;</span>
            <span class="nt">&lt;artifactId&gt;</span>activiti-engine<span class="nt">&lt;/artifactId&gt;</span>
            <span class="nt">&lt;version&gt;</span>${activiti-version}<span class="nt">&lt;/version&gt;</span>
        <span class="nt">&lt;/dependency&gt;</span>

        <span class="c">&lt;!--mysql驱动--&gt;</span>
        <span class="nt">&lt;dependency&gt;</span>
            <span class="nt">&lt;groupId&gt;</span>mysql<span class="nt">&lt;/groupId&gt;</span>
            <span class="nt">&lt;artifactId&gt;</span>mysql-connector-java<span class="nt">&lt;/artifactId&gt;</span>
            <span class="nt">&lt;version&gt;</span>${mysql-version}<span class="nt">&lt;/version&gt;</span>
        <span class="nt">&lt;/dependency&gt;</span>

        <span class="c">&lt;!--log4j日志--&gt;</span>
        <span class="nt">&lt;dependency&gt;</span>
            <span class="nt">&lt;groupId&gt;</span>org.slf4j<span class="nt">&lt;/groupId&gt;</span>
            <span class="nt">&lt;artifactId&gt;</span>slf4j-log4j12<span class="nt">&lt;/artifactId&gt;</span>
            <span class="nt">&lt;version&gt;</span>${sl4j-log4j-version}<span class="nt">&lt;/version&gt;</span>
        <span class="nt">&lt;/dependency&gt;</span>

        <span class="c">&lt;!--junit测试--&gt;</span>
        <span class="nt">&lt;dependency&gt;</span>
            <span class="nt">&lt;groupId&gt;</span>junit<span class="nt">&lt;/groupId&gt;</span>
            <span class="nt">&lt;artifactId&gt;</span>junit<span class="nt">&lt;/artifactId&gt;</span>
            <span class="nt">&lt;version&gt;</span>${junit-version}<span class="nt">&lt;/version&gt;</span>
        <span class="nt">&lt;/dependency&gt;</span>

    <span class="nt">&lt;/dependencies&gt;</span>
</code></pre></td></tr></table>
</div>
</div><h3 id="activiti配置">Activiti配置</h3>
<h4 id="创建-processengine">创建 ProcessEngine</h4>
<p>通过配置文件<code>activiti.cfg.xml</code>配置流程引擎的相关信息，如下：</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre class="chroma"><code><span class="lnt"> 1
</span><span class="lnt"> 2
</span><span class="lnt"> 3
</span><span class="lnt"> 4
</span><span class="lnt"> 5
</span><span class="lnt"> 6
</span><span class="lnt"> 7
</span><span class="lnt"> 8
</span><span class="lnt"> 9
</span><span class="lnt">10
</span><span class="lnt">11
</span><span class="lnt">12
</span><span class="lnt">13
</span><span class="lnt">14
</span><span class="lnt">15
</span><span class="lnt">16
</span><span class="lnt">17
</span><span class="lnt">18
</span><span class="lnt">19
</span><span class="lnt">20
</span><span class="lnt">21
</span><span class="lnt">22
</span><span class="lnt">23
</span><span class="lnt">24
</span><span class="lnt">25
</span><span class="lnt">26
</span><span class="lnt">27
</span><span class="lnt">28
</span><span class="lnt">29
</span><span class="lnt">30
</span><span class="lnt">31
</span><span class="lnt">32
</span><span class="lnt">33
</span><span class="lnt">34
</span><span class="lnt">35
</span><span class="lnt">36
</span><span class="lnt">37
</span><span class="lnt">38
</span><span class="lnt">39
</span></code></pre></td>
<td class="lntd">
<pre class="chroma"><code class="language-xml" data-lang="xml"><span class="cp">&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;</span>
<span class="nt">&lt;beans</span> <span class="na">xmlns=</span><span class="s">&#34;http://www.springframework.org/schema/beans&#34;</span>
       <span class="na">xmlns:xsi=</span><span class="s">&#34;http://www.w3.org/2001/XMLSchema-instance&#34;</span>
       <span class="na">xsi:schemaLocation=</span><span class="s">&#34;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd&#34;</span><span class="nt">&gt;</span>

    <span class="nt">&lt;bean</span> <span class="na">id=</span><span class="s">&#34;processEngineConfiguration&#34;</span> <span class="na">class=</span><span class="s">&#34;org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration&#34;</span><span class="nt">&gt;</span>
        <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&#34;databaseType&#34;</span> <span class="na">value=</span><span class="s">&#34;mysql&#34;</span> <span class="nt">/&gt;</span>

        <span class="c">&lt;!--
</span><span class="c">        生命数据库脚本更新策略
</span><span class="c">            false: 表示什么都不做
</span><span class="c">            true: 当act表不存在时自动创建，jar版本与数据库内记录的版本不一致时自动执行升级脚本，并记录升级过程
</span><span class="c">            create-drop: 创建引擎时初始化脚本，引擎销毁时执行删除脚本
</span><span class="c">       --&gt;</span>
        <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&#34;databaseSchemaUpdate&#34;</span> <span class="na">value=</span> <span class="s">&#34;true&#34;</span><span class="nt">/&gt;</span>

        <span class="c">&lt;!--
</span><span class="c">          是否启用作业执行功能，默认为false。如果设置为true,会不断刷新作业表，存在作业就触发
</span><span class="c">        --&gt;</span>
        <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&#34;jobExecutorActivate&#34;</span> <span class="na">value=</span> <span class="s">&#34;false&#34;</span><span class="nt">/&gt;</span>

        <span class="c">&lt;!--
</span><span class="c">        记录历史的级别，默认为audit
</span><span class="c">            none: 不保存任何历史记录，可提高系统性能
</span><span class="c">            activity: 保存所有流程实例、任务、活动信息
</span><span class="c">            audit: 保存所有流程实例、任务、活动、表单属性。
</span><span class="c">            full: 完整的历史记录，包含audit以外还有其它记录，如流程变量、表单属性等
</span><span class="c">        --&gt;</span>
        <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&#34;history&#34;</span> <span class="na">value=</span> <span class="s">&#34;audit&#34;</span><span class="nt">/&gt;</span>

        <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&#34;jdbcDriver&#34;</span> <span class="na">value=</span><span class="s">&#34;com.mysql.cj.jdbc.Driver&#34;</span> <span class="nt">/&gt;</span>
        <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&#34;jdbcUrl&#34;</span> <span class="na">value=</span><span class="s">&#34;jdbc:mysql://127.0.0.1:3306/act-test?characterEncoding=UTF-8&amp;amp;
</span><span class="s">        useUnicode=true&amp;amp;useSSL=false&amp;amp;tinyInt1isBit=false&amp;amp;allowPublicKeyRetrieval=true&amp;amp;
</span><span class="s">        serverTimezone=UTC&amp;amp;nullCatalogMeansCurrent=true&#34;</span> <span class="nt">/&gt;</span>
        <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&#34;jdbcUsername&#34;</span> <span class="na">value=</span><span class="s">&#34;root&#34;</span> <span class="nt">/&gt;</span>
        <span class="nt">&lt;property</span> <span class="na">name=</span><span class="s">&#34;jdbcPassword&#34;</span> <span class="na">value=</span><span class="s">&#34;root&#34;</span> <span class="nt">/&gt;</span>

    <span class="nt">&lt;/bean&gt;</span>
<span class="nt">&lt;/beans&gt;</span>
</code></pre></td></tr></table>
</div>
</div><p>可通过以下方法启动并创建<code>Activiti</code>数据表</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre class="chroma"><code><span class="lnt"> 1
</span><span class="lnt"> 2
</span><span class="lnt"> 3
</span><span class="lnt"> 4
</span><span class="lnt"> 5
</span><span class="lnt"> 6
</span><span class="lnt"> 7
</span><span class="lnt"> 8
</span><span class="lnt"> 9
</span><span class="lnt">10
</span><span class="lnt">11
</span><span class="lnt">12
</span><span class="lnt">13
</span><span class="lnt">14
</span><span class="lnt">15
</span><span class="lnt">16
</span><span class="lnt">17
</span><span class="lnt">18
</span><span class="lnt">19
</span><span class="lnt">20
</span><span class="lnt">21
</span><span class="lnt">22
</span><span class="lnt">23
</span><span class="lnt">24
</span><span class="lnt">25
</span><span class="lnt">26
</span><span class="lnt">27
</span><span class="lnt">28
</span><span class="lnt">29
</span><span class="lnt">30
</span><span class="lnt">31
</span><span class="lnt">32
</span><span class="lnt">33
</span><span class="lnt">34
</span><span class="lnt">35
</span><span class="lnt">36
</span><span class="lnt">37
</span><span class="lnt">38
</span><span class="lnt">39
</span><span class="lnt">40
</span><span class="lnt">41
</span><span class="lnt">42
</span><span class="lnt">43
</span><span class="lnt">44
</span><span class="lnt">45
</span><span class="lnt">46
</span><span class="lnt">47
</span><span class="lnt">48
</span><span class="lnt">49
</span><span class="lnt">50
</span><span class="lnt">51
</span><span class="lnt">52
</span><span class="lnt">53
</span><span class="lnt">54
</span></code></pre></td>
<td class="lntd">
<pre class="chroma"><code class="language-java" data-lang="java"><span class="kn">package</span> <span class="nn">com.fn2xn.act01</span><span class="o">;</span>

<span class="kn">import</span> <span class="nn">org.activiti.engine.ProcessEngine</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.activiti.engine.ProcessEngineConfiguration</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.activiti.engine.ProcessEngines</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.junit.Test</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.slf4j.Logger</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.slf4j.LoggerFactory</span><span class="o">;</span>

<span class="cm">/**
</span><span class="cm"> * @Description 初始化Activiti表测试
</span><span class="cm"> * @Author fn2xn
</span><span class="cm"> * @date 2020/11/16 11:24
</span><span class="cm"> */</span>
<span class="kd">public</span> <span class="kd">class</span> <span class="nc">InitProcessEngineTest</span> <span class="o">{</span>

    <span class="kd">private</span> <span class="kd">static</span> <span class="kd">final</span> <span class="n">Logger</span> <span class="n">logger</span> <span class="o">=</span> <span class="n">LoggerFactory</span><span class="o">.</span><span class="na">getLogger</span><span class="o">(</span><span class="n">InitProcessEngineTest</span><span class="o">.</span><span class="na">class</span><span class="o">);</span>
    <span class="cm">/**
</span><span class="cm">     * 建表方式一,读取根目录下的配置文件
</span><span class="cm">     */</span>
    <span class="nd">@Test</span>
    <span class="kd">public</span> <span class="kt">void</span> <span class="nf">initMode1Test</span><span class="o">(){</span>
        <span class="n">ProcessEngine</span> <span class="n">processEngine</span> <span class="o">=</span> <span class="n">ProcessEngineConfiguration</span>
                <span class="o">.</span><span class="na">createProcessEngineConfigurationFromResource</span><span class="o">(</span><span class="s">&#34;activiti.cfg.xml&#34;</span><span class="o">)</span>
                <span class="o">.</span><span class="na">buildProcessEngine</span><span class="o">();</span>
        <span class="n">logger</span><span class="o">.</span><span class="na">info</span><span class="o">(</span><span class="s">&#34;方式一=============={}&#34;</span><span class="o">,</span> <span class="n">processEngine</span><span class="o">);</span>
    <span class="o">}</span>
    <span class="cm">/**
</span><span class="cm">     * 建表方式二
</span><span class="cm">     */</span>
    <span class="nd">@Test</span>
    <span class="kd">public</span> <span class="kt">void</span> <span class="nf">initMode2Test</span><span class="o">(){</span>
        <span class="n">ProcessEngine</span> <span class="n">processEngine</span> <span class="o">=</span> <span class="n">ProcessEngineConfiguration</span><span class="o">.</span><span class="na">createStandaloneProcessEngineConfiguration</span><span class="o">()</span>
                <span class="o">.</span><span class="na">setJdbcDriver</span><span class="o">(</span><span class="s">&#34;com.mysql.cj.jdbc.Driver&#34;</span><span class="o">)</span>
                <span class="o">.</span><span class="na">setJdbcUrl</span><span class="o">(</span><span class="s">&#34;jdbc:mysql://127.0.0.1:3306/act-test?characterEncoding=UTF-8&amp;useUnicode=true&amp;useSSL=false&amp;tinyInt1isBit=false&amp;allowPublicKeyRetrieval=true&amp;serverTimezone=UTC&amp;nullCatalogMeansCurrent=true&#34;</span><span class="o">)</span>
                <span class="o">.</span><span class="na">setJdbcUsername</span><span class="o">(</span><span class="s">&#34;root&#34;</span><span class="o">)</span>
                <span class="o">.</span><span class="na">setJdbcPassword</span><span class="o">(</span><span class="s">&#34;root&#34;</span><span class="o">)</span>
                <span class="o">.</span><span class="na">setDatabaseSchemaUpdate</span><span class="o">(</span><span class="n">ProcessEngineConfiguration</span><span class="o">.</span><span class="na">DB_SCHEMA_UPDATE_TRUE</span><span class="o">)</span>
                <span class="o">.</span><span class="na">buildProcessEngine</span><span class="o">();</span>
        <span class="n">logger</span><span class="o">.</span><span class="na">info</span><span class="o">(</span><span class="s">&#34;方式二=============={}&#34;</span><span class="o">,</span> <span class="n">processEngine</span><span class="o">);</span>
    <span class="o">}</span>
    <span class="cm">/**
</span><span class="cm">     * 建表方式三
</span><span class="cm">     */</span>
    <span class="nd">@Test</span>
    <span class="kd">public</span> <span class="kt">void</span> <span class="nf">initMode3Test</span><span class="o">(){</span>
        <span class="kt">char</span><span class="o">[]</span> <span class="n">chars</span> <span class="o">=</span> <span class="s">&#34;&#34;</span><span class="o">.</span><span class="na">toCharArray</span><span class="o">();</span>
        <span class="c1">// 默认去寻找根目录下的 activiti.cfg.xml文件
</span><span class="c1"></span>        <span class="n">ProcessEngine</span> <span class="n">processEngine</span> <span class="o">=</span> <span class="n">ProcessEngines</span><span class="o">.</span><span class="na">getDefaultProcessEngine</span><span class="o">();</span>
        <span class="n">logger</span><span class="o">.</span><span class="na">info</span><span class="o">(</span><span class="s">&#34;方式三=============={}&#34;</span><span class="o">,</span> <span class="n">processEngine</span><span class="o">);</span>
    <span class="o">}</span>

<span class="o">}</span>

</code></pre></td></tr></table>
</div>
</div><p>源码链接：<a href="https://github.com/dou-chi/some-practise/tree/master/activiti-practise/act-module-01" target="_blank" rel="noopener noreffer">https://github.com/dou-chi/some-practise/tree/master/activiti-practise/act-module-01</a></p>
<h4 id="表说明">表说明</h4>
<p>Activiti 数据库中表的命名都是以 ACT_开头的。第二部分是一个两个字符用例表的标识。此用例大体与服务 API 是匹配的。</p>
<ul>
<li>
<p>ACT_RE_*：’RE’代表 repository。带此前缀的表包含的是静态信息，如，流程定义、流程的资源（图片、规则，等）。</p>
</li>
<li>
<p>ACT_RU_*：’RU’代表 runtime。就是这个运行时的表存储着流程变量、用户任务、变量、作业，等中的运行时的数据。
Activiti 只存储流程实例执行期间的运行时数据，当流程实例结束时，将删除这些记录。这就使这些运行时的表保持
的小且快。</p>
</li>
<li>
<p>ACT_ID_*：’ID’代表 identity。这些表包含着标识的信息，如用户、用户组、等等。</p>
</li>
<li>
<p>ACT_HI_*：’HI’代表 history。就是这些表包含着历史的相关数据，如结束的流程实例、变量、任务、等等。</p>
</li>
<li>
<p>ACT_GE_*：普通数据，各种情况都使用的数据。</p>
<p>常用的查询SQL</p>
</li>
</ul>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre class="chroma"><code><span class="lnt"> 1
</span><span class="lnt"> 2
</span><span class="lnt"> 3
</span><span class="lnt"> 4
</span><span class="lnt"> 5
</span><span class="lnt"> 6
</span><span class="lnt"> 7
</span><span class="lnt"> 8
</span><span class="lnt"> 9
</span><span class="lnt">10
</span><span class="lnt">11
</span><span class="lnt">12
</span><span class="lnt">13
</span><span class="lnt">14
</span><span class="lnt">15
</span><span class="lnt">16
</span><span class="lnt">17
</span><span class="lnt">18
</span><span class="lnt">19
</span><span class="lnt">20
</span><span class="lnt">21
</span><span class="lnt">22
</span><span class="lnt">23
</span><span class="lnt">24
</span><span class="lnt">25
</span><span class="lnt">26
</span><span class="lnt">27
</span></code></pre></td>
<td class="lntd">
<pre class="chroma"><code class="language-sql" data-lang="sql"><span class="o">#</span><span class="n">RepositoryService</span>
<span class="k">SELECT</span> <span class="o">*</span> <span class="k">FROM</span> <span class="o">`</span><span class="n">act_ge_bytearray</span><span class="o">`</span><span class="p">;</span> <span class="o">#</span><span class="err">二进制文件表</span>
<span class="k">SELECT</span> <span class="o">*</span> <span class="k">FROM</span> <span class="o">`</span><span class="n">act_re_deployment</span><span class="o">`</span><span class="p">;</span><span class="o">#</span><span class="err">流程部署表</span>
<span class="k">SELECT</span> <span class="o">*</span> <span class="k">FROM</span> <span class="o">`</span><span class="n">act_re_procdef</span><span class="o">`</span><span class="p">;</span><span class="o">#</span><span class="err">流程定义</span>
<span class="k">SELECT</span> <span class="o">*</span> <span class="k">FROM</span> <span class="o">`</span><span class="n">act_ge_property</span><span class="o">`</span><span class="p">;</span><span class="o">#</span><span class="err">工作流的</span><span class="n">ID算法和版本信息表</span>

<span class="o">#</span><span class="n">RuntimeService</span>   <span class="n">TaskService</span>
<span class="k">SELECT</span> <span class="o">*</span> <span class="k">FROM</span> <span class="o">`</span><span class="n">act_ru_execution</span><span class="o">`</span><span class="p">;</span><span class="o">#</span><span class="err">流程启动一次只要没有执行完，就会有一条数据</span>
<span class="k">SELECT</span> <span class="o">*</span> <span class="k">FROM</span> <span class="o">`</span><span class="n">act_ru_task</span><span class="o">`</span><span class="p">;</span><span class="o">#</span><span class="err">可能有多条数据</span>
<span class="k">SELECT</span> <span class="o">*</span> <span class="k">FROM</span> <span class="o">`</span><span class="n">act_ru_variable</span><span class="o">`</span><span class="p">;</span><span class="o">#</span><span class="err">记录流程运行时的流程变量</span>
<span class="k">SELECT</span> <span class="o">*</span> <span class="k">FROM</span> <span class="o">`</span><span class="n">act_ru_identitylink</span><span class="o">`</span><span class="p">;</span><span class="o">#</span><span class="err">存放流程办理人的信息</span>

<span class="o">#</span><span class="n">HistroyService</span>
<span class="k">SELECT</span> <span class="o">*</span> <span class="k">FROM</span> <span class="o">`</span><span class="n">act_hi_procinst</span><span class="o">`</span><span class="p">;</span><span class="o">#</span><span class="err">历史流程实例</span>
<span class="k">SELECT</span> <span class="o">*</span> <span class="k">FROM</span> <span class="o">`</span><span class="n">act_hi_taskinst</span><span class="o">`</span><span class="p">;</span><span class="o">#</span><span class="err">历史任务实例</span>
<span class="k">SELECT</span> <span class="o">*</span> <span class="k">FROM</span> <span class="o">`</span><span class="n">act_hi_actinst</span><span class="o">`</span><span class="p">;</span><span class="o">#</span><span class="err">历史活动节点表</span>
<span class="k">SELECT</span> <span class="o">*</span> <span class="k">FROM</span> <span class="o">`</span><span class="n">act_hi_varinst</span><span class="o">`</span><span class="p">;</span><span class="o">#</span><span class="err">历史流程变量表</span>
<span class="k">SELECT</span> <span class="o">*</span> <span class="k">FROM</span> <span class="o">`</span><span class="n">act_hi_identitylink</span><span class="o">`</span><span class="p">;</span><span class="o">##</span><span class="err">历史办理人表</span>
<span class="k">SELECT</span> <span class="o">*</span> <span class="k">FROM</span> <span class="o">`</span><span class="n">act_hi_comment</span><span class="o">`</span><span class="p">;</span><span class="o">#</span><span class="err">批注表</span>
<span class="k">SELECT</span> <span class="o">*</span> <span class="k">FROM</span> <span class="o">`</span><span class="n">act_hi_attachment</span><span class="o">`</span><span class="p">;</span><span class="o">#</span><span class="err">附件表</span>

<span class="o">#</span><span class="n">IdentityService</span>
<span class="k">SELECT</span> <span class="o">*</span> <span class="k">FROM</span> <span class="o">`</span><span class="n">act_id_group</span><span class="o">`</span> <span class="o">#</span><span class="err">角色</span>
<span class="k">SELECT</span> <span class="o">*</span> <span class="k">FROM</span> <span class="o">`</span><span class="n">act_id_membership</span><span class="o">`#</span><span class="err">用户和角色之间的关系</span>
<span class="k">SELECT</span> <span class="o">*</span> <span class="k">FROM</span> <span class="o">`</span><span class="n">act_id_info</span><span class="o">`#</span><span class="err">用户的详细信息</span>
<span class="k">SELECT</span> <span class="o">*</span> <span class="k">FROM</span> <span class="o">`</span><span class="n">act_id_user</span><span class="o">`#</span><span class="err">用户表</span>

</code></pre></td></tr></table>
</div>
</div></div><div class="post-footer" id="post-footer">
    <div class="post-info">
        <div class="post-info-line">
            <div class="post-info-mod">
                <span>更新于 2020-11-16</span>
            </div>
            <div class="post-info-license"></div>
        </div>
        <div class="post-info-line">
            <div class="post-info-md"><span>
                            <a class="link-to-markdown" href="/activiti%E4%BA%8C%E5%88%9D%E5%A7%8B%E5%8C%96/index.md" target="_blank">阅读原始文档</a>
                        </span></div>
            <div class="post-info-share">
                <span><a href="javascript:void(0);" title="分享到 Twitter" data-sharer="twitter" data-url="https://dou-chi.gitee.io/activiti%E4%BA%8C%E5%88%9D%E5%A7%8B%E5%8C%96/" data-title="Activiti（二）初始化" data-hashtags="Activiti"><i class="fab fa-twitter fa-fw"></i></a><a href="javascript:void(0);" title="分享到 Facebook" data-sharer="facebook" data-url="https://dou-chi.gitee.io/activiti%E4%BA%8C%E5%88%9D%E5%A7%8B%E5%8C%96/" data-hashtag="Activiti"><i class="fab fa-facebook-square fa-fw"></i></a><a href="javascript:void(0);" title="分享到 WhatsApp" data-sharer="whatsapp" data-url="https://dou-chi.gitee.io/activiti%E4%BA%8C%E5%88%9D%E5%A7%8B%E5%8C%96/" data-title="Activiti（二）初始化" data-web><i class="fab fa-whatsapp fa-fw"></i></a><a href="javascript:void(0);" title="分享到 Line" data-sharer="line" data-url="https://dou-chi.gitee.io/activiti%E4%BA%8C%E5%88%9D%E5%A7%8B%E5%8C%96/" data-title="Activiti（二）初始化"><i data-svg-src="/lib/simple-icons/icons/line.min.svg"></i></a><a href="javascript:void(0);" title="分享到 微博" data-sharer="weibo" data-url="https://dou-chi.gitee.io/activiti%E4%BA%8C%E5%88%9D%E5%A7%8B%E5%8C%96/" data-title="Activiti（二）初始化"><i class="fab fa-weibo fa-fw"></i></a><a href="javascript:void(0);" title="分享到 Myspace" data-sharer="myspace" data-url="https://dou-chi.gitee.io/activiti%E4%BA%8C%E5%88%9D%E5%A7%8B%E5%8C%96/" data-title="Activiti（二）初始化" data-description="Activiti 初始化"><i data-svg-src="/lib/simple-icons/icons/myspace.min.svg"></i></a><a href="javascript:void(0);" title="分享到 Blogger" data-sharer="blogger" data-url="https://dou-chi.gitee.io/activiti%E4%BA%8C%E5%88%9D%E5%A7%8B%E5%8C%96/" data-title="Activiti（二）初始化" data-description="Activiti 初始化"><i class="fab fa-blogger fa-fw"></i></a><a href="javascript:void(0);" title="分享到 Evernote" data-sharer="evernote" data-url="https://dou-chi.gitee.io/activiti%E4%BA%8C%E5%88%9D%E5%A7%8B%E5%8C%96/" data-title="Activiti（二）初始化"><i class="fab fa-evernote fa-fw"></i></a></span>
            </div>
        </div>
    </div>

    <div class="post-info-more">
        <section class="post-tags"><i class="fas fa-tags fa-fw"></i>&nbsp;<a href="/tags/activiti/">Activiti</a></section>
        <section>
            <span><a href="javascript:void(0);" onclick="window.history.back();">返回</a></span>&nbsp;|&nbsp;<span><a href="/">主页</a></span>
        </section>
    </div>

    <div class="post-nav"><a href="/activiti%E4%B8%80%E7%AE%80%E4%BB%8B/" class="prev" rel="prev" title="Activiti（一）简介"><i class="fas fa-angle-left fa-fw"></i>Activiti（一）简介</a>
            <a href="/actdynamicprocess/" class="next" rel="next" title="在Activiti中实现动态流程（修改流程图重新发布后对正在运行的流程生效）">在Activiti中实现动态流程（修改流程图重新发布后对正在运行的流程生效）<i class="fas fa-angle-right fa-fw"></i></a></div>
</div>
<div id="comments"></div></article></div>
            </main><footer class="footer">
        <div class="footer-container"><div class="footer-line">由 <a href="https://gohugo.io/" target="_blank" rel="noopener noreffer" title="Hugo 0.74.3">Hugo</a> 强力驱动 | 主题 - <a href="https://github.com/dillonzq/LoveIt" target="_blank" rel="noopener noreffer" title="LoveIt 0.2.10"><i class="far fa-kiss-wink-heart fa-fw"></i> LoveIt</a>
                </div><div class="footer-line"><i class="far fa-copyright fa-fw"></i><span itemprop="copyrightYear">2019 - 2021</span><span class="author" itemprop="copyrightHolder">&nbsp;<a href="/" target="_blank">豆是不吃豆豉</a></span></div>
        </div>
    </footer></div>

        <div id="fixed-buttons"><a href="#" id="back-to-top" class="fixed-button" title="回到顶部">
                <i class="fas fa-arrow-up fa-fw"></i>
            </a><a href="#" id="view-comments" class="fixed-button" title="查看评论">
                <i class="fas fa-comment fa-fw"></i>
            </a>
        </div><link rel="stylesheet" href="/lib/katex/katex.min.css"><link rel="stylesheet" href="/lib/katex/copy-tex.min.css"><link rel="stylesheet" href="/lib/cookieconsent/cookieconsent.min.css"><script type="text/javascript" src="/lib/smooth-scroll/smooth-scroll.min.js"></script><script type="text/javascript" src="/lib/autocomplete/autocomplete.min.js"></script><script type="text/javascript" src="/lib/lunr/lunr.min.js"></script><script type="text/javascript" src="/lib/lunr/lunr.stemmer.support.min.js"></script><script type="text/javascript" src="/lib/lunr/lunr.zh.min.js"></script><script type="text/javascript" src="/lib/lazysizes/lazysizes.min.js"></script><script type="text/javascript" src="/lib/clipboard/clipboard.min.js"></script><script type="text/javascript" src="/lib/sharer/sharer.min.js"></script><script type="text/javascript" src="/lib/katex/katex.min.js"></script><script type="text/javascript" src="/lib/katex/auto-render.min.js"></script><script type="text/javascript" src="/lib/katex/copy-tex.min.js"></script><script type="text/javascript" src="/lib/katex/mhchem.min.js"></script><script type="text/javascript" src="/lib/cookieconsent/cookieconsent.min.js"></script><script type="text/javascript">window.config={"code":{"copyTitle":"复制到剪贴板","maxShownLines":100},"comment":{},"cookieconsent":{"content":{"dismiss":"同意","link":"了解更多","message":"本网站使用 Cookies 来改善您的浏览体验."},"enable":true,"palette":{"button":{"background":"#f0f0f0"},"popup":{"background":"#1aa3ff"}},"theme":"edgeless"},"math":{"delimiters":[{"display":true,"left":"$$","right":"$$"},{"display":true,"left":"\\[","right":"\\]"},{"display":false,"left":"$","right":"$"},{"display":false,"left":"\\(","right":"\\)"}],"strict":false},"search":{"highlightTag":"em","lunrIndexURL":"/index.json","lunrLanguageCode":"zh","lunrSegmentitURL":"/lib/lunr/lunr.segmentit.js","maxResultLength":10,"noResultsFound":"没有找到结果","snippetLength":50,"type":"lunr"}};</script><script type="text/javascript" src="/js/theme.min.js"></script></body>
</html>
